#include <iostream>
#include <functional>
#include <string>
class Task
{
public:
    using func_t = std::function<int(int, int,char)>;

public:
    Task() {} // 无参构造函数
    Task(int x, int y, char op, func_t func) : _x(x), _y(y), _op(op), _func(func)
    {
    }
    std::string operator()()
    {
        int result = _func(_x,_y,_op);
        char buffer[128];
        snprintf(buffer,sizeof buffer,"%d %c %d = %d",_x,_op,_y,result);
        return buffer;
    }

    std::string Tostring()
    {
        char namebuffer[1024];
        snprintf(namebuffer, sizeof namebuffer, "%d %c %d = ?", _x, _op, _y);
        return namebuffer;
    }

private:
    int _x;
    int _y;
    char _op;
    func_t _func;
};

const std::string opera = "+-*/%";
int myMath(int x, int y, char op)
{
    int result;
    switch (op)
    {
    case '+':
        result = x + y;
        break;
    case '-':
        result = x - y;
        break;
    case '*':
        result = x * y;
        break;
    case '/':
        if (y == 0)
        {
            std::cout << "DIV error" << std::endl;
            result = -1;
        }
        result = x / y;
        break;
    case '%':
        if (y == 0)
        {
            std::cout << "Mod error" << std::endl;
            result = -1;
        }
        result = x % y;
        break;
    default:
        break;
    }
    return result;
}
